#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;

class CShape {
	public:
		virtual double Area() = 0;
		virtual double Printlnfo() = 0;
};

class CRectangle: public CShape {
	public:
		int w, h;
		virtual double Area();
		virtual double Printlnfo();
};

class CCirle: public CShape {
	public:
		int r;
		virtual double Area();
		virtual double Printlnfo();
};

class CA: public CShape {
	public:
		int h, d1, d2;
		virtual double Area();
		virtual double Printlnfo();
};

class CTrianngle: public CShape {
	public:
		int a, b, c;
		virtual double Area();
		virtual double Printlnfo();
};

double CRectangle::Area() {
	return w * h;
}

void CRectangle::Printlnfo() {
	cout << "Rectangle:" << Area() << endl;
}

double CA::Area() {
	return (d1 + d2) * h / 2;
}

void CA::Printlnfo() {
	cout << "A:" << Area() << endl;
}

double CCirle::Area() {
	return 3.14 * r * r;
}

void CCirle::Printlnfo() {
	cout << "Cirle:" << Area() << endl;
}

double CTriangle::Area() {
	double p = (a + b + c) / 2.0;
	return sqrt(p * (p - a) * (p - b) * (p - c));
}

void CTriangle::Pritlnfo() {
	cout << "Triangle:" << Area() << endl;
}
CShape *pShapes[100];

int MyCompare(const void *s1, const void *s2) {
	double a1, a2;
	CShape **p1;
	CShape **p2;
	p1 = (CShape **)s1;
	p2 = (CShape **)s2;
	a1 = (*p1) - Area();
	a2 = (*p2)->Area();
	if (a1 < a2)
		return -1;
	else if (a2 < a1)
		return 1;
	else
		return 0;
}

int main() {
	int i;
	int n;
	CRectangle *pr;
	CCirle *pc;
	CTriangle *pt;
	CA *pa;
	cin >> n;
	for (i = 0; i < n; ++i) {
		char c;
		cin >> c;
		switch (c) {
			case'R':
				pr = new CRectangle();
				cin >> pr->w >> pr->h;
				pShapes[i] = pr;
				break;
			case'C':
					pc = new CCirle();
				cin >> pc->r;
				pShapes[i] = pc;
				break;
			case'T':
				pt = new CTriangle();
				cin >> pt->a >> pt->b >> pt->c;
				pShapes[i] = pt;
				break;
			case'A':
					pa = new CA();
				cin >> pa->d1 >> pa->d2 >> pa->h;
				pShapes[i] = pa;
				break;
		}
	}
	qsort(pShapes, n, sizeof(CShape *), MyCompare);
	for (i = 0; i < n; ++i)
		pShapes[i]->Printlnfo();
	delete pShapes[i];
	return 0;
}